#include <stdio.h>
#include "types.h"
#include "queue.h"

typedef struct node_t {
    i32 value;
    void *next;
} node_t;

typedef struct queue_t {
    node_t *head;
    node_t *tail;
} queue_t;

void queue_print(queue_t *queue) {
    printf("queue contents:\n  ");
    node_t *ptr = queue->head;
    while(ptr) {
        printf("%d ", ptr->value);
        ptr = ptr->next;
    }
    printf("\n");
}

int main(void) {
    queue_t *data = malloc(sizeof(*data));
    data->head = NULL;
    data->tail = NULL;
    enqueue(data, 0);
    for (u8 i=1; i<=25; ++i) {
        enqueue(data, i);
    }
    i32 value = -1;
    dequeue(data, &value);
    assert(value == 0 && "Failed to dequeue.");
    queue_print(data);
    queue_free(data);
    assert(data->head == NULL && data->tail == NULL && "Failed to empty queue.");
    free(data);
    return 0;
}